{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 1\n",
    "\n",
    "##### Main components of credit risk\n",
    "$$ E[loss]=PD \\times LGD \\times EAD$$\n",
    "\n",
    "- __Probability of default__ \n",
    "  > Mitigate with __Guarantee__ or __CDS__\n",
    "- __Exposure at default__ ( Potential future exposure , notional value)\n",
    "  > mitigate with __Netting__\n",
    "- loss Given Default \n",
    "  > Mitigate with __collateral__\n",
    "\n",
    "##### Other stuffs\n",
    "- Procyclicality \n",
    "  > PD and LGD move together because of business cycle\n",
    "- Wrong way risk\n",
    "  > PD and EAD move together. When people know they will default they draw on their credit \n",
    "\n",
    "- LGD can be >1\n",
    "Collection process also costs money and human capital \n",
    "\n",
    "- LGD <0 Penalty in case of default + you have access to taxation. Municipalities like the Lannisters always pay their debts \n",
    "- S&P rating \n",
    "  >AAA - AA - A - __BBB__(investment grade) - __BB__(speculative)- B - CCC - D\n",
    "- __Credit Scoring__\n",
    "Through the cycle( what we did) versus Point in Time\n",
    "  >  Difficult to backtest credit risk \n",
    "\n",
    "- Migration Matrix Regularization\n",
    "Need to do shit to it to make it better behaved \n",
    "\n",
    "# Chapter 2\n",
    "You know this shit better than me \n",
    "# Chapter 3\n",
    "Estimating PD\n",
    "1. Historical data\n",
    "2. Credit Ratings\n",
    "3. CDS \n",
    "4. Merton-like models\n",
    "\n",
    "#### Merton model\n",
    "- If Assets are smaller than  Liabilities then the company  defaults.  \n",
    "\n",
    "- Assets = underlying latent variable.  \n",
    "\n",
    "- Liabilities = default barrier \n",
    "- Use option pricing --> Equity is a European call option on the Assets. \n",
    "\n",
    "$$Pr(Default) = P(A(t)<DB) = 1-N(d2) = N(-d2)$$\n",
    "\n",
    "__Flaws of the model__\n",
    "> - Can not observe Asset volatility(deduce from equity volatility)\n",
    "> - Can not observe Asset Prices\n",
    "> - It's not a European option but a __Barrier__ option\n",
    "> - The world is not Gaussian\n",
    "> - We should be using real world measure not risk neutral measure\n",
    "##### KMV Moody's = Extension Maturity\n",
    "- Moody's works with the notion of distance to default = how many standard deviations am I from default\n",
    "- $N( -d2)$ is estimated from proprietary data set \n",
    "- Takes into account first passage idea of Barrier option\n",
    "- Default barrier is estimated more accurately(short term liabilities blabla)\n",
    "##### Inferring PD from market : Credit Default Swap\n",
    "__Definition__ : Contract where company A has the right to sell a bond issued by company C for its face value to company B in the event of default\n",
    "- Fix Recovery rate at 40% = market convention Goldman Sachs\n",
    "- Protection Buyer Versus Protection Seller\n",
    "- Spread = premium = Bond yield - risk free Bond\n",
    "- Getting Default term structure : too many payments for too little CDS quotes.  \n",
    "\n",
    "__Solution__\n",
    "1. Bootstrapping --> possible to get negative Spread\n",
    "2. The Martin-Thompson Approach solves this\n",
    "# Chapter 4 \n",
    "1. Expected Loss = Cost of doing Business \n",
    "2. Unexpected Loss\n",
    "> - Risk Capital\n",
    ">- Economic Capital\n",
    "\n",
    "Basel Capital requirements refer to unexpected losses \n",
    "\n",
    "- `Copula` a construct to link the independent marginal distributions to a joint distribution\n",
    "- __Attributes Risk Measure__ :\n",
    "VAR violates in some cases sub-additivity(especially for non granular portfolios ):\n",
    "$$VAR(a+b)> Var(a)+ Var(b)) $$\n",
    "Don't have this problem for Expected Shortfall\n",
    "- __Correlation Modelling__\n",
    "Define Correlation through factors :\n",
    "> 1. Basel Formula has 1 factor \n",
    "> 2. __CreditMetrics__ : 2 factors Country, Industry  --> Calibrate on industry Country indices e.g CAC40 , FTSE100\n",
    "\n",
    "#### Basel III formula \n",
    "- One factor model where number of obligors goes to infinity\n",
    "- Analytic Solution\n",
    "- Exact contribution to Value at Risk \n",
    "- __Conditional independence__ : Given that I know state of factor variable, I can move conditional expectation of loss distribution inside value at risk operator\n",
    "- __Maturity Adjustment__ To take into account rating changes, biug\n",
    "\n",
    "__Problems with Basel Formula__ \n",
    " assumes large protfolios with small exposures. Breaks down if you have one big counterparty , creates a kink in loss distribution\n",
    " \n",
    "# Chapter 5 Credit Risk +\n",
    "lots of Math --> Poisson distribution\n",
    "Exact analytic solution \n",
    "\n",
    "\n",
    "# Chapter 6 \n",
    "__Stress Testing__\n",
    "\n",
    "1. Sensitivity analysis Bottom up = Move market variables : yield curve , spot volatilities, rating changes\n",
    "2. Event driven Scenario analysis = Top down --> look at big event\n",
    "\n",
    "### Potential Future Exposure\n",
    "__Definition__ :“If my client defaults in x-months from now, how much am I likely to lose at a given Confidence Level?” \n",
    "= Potential future Mark to market = Future Cost of Replacement\n",
    "Provides a link between market and credit risk.\n",
    "\n",
    "\" What is the potential future exposure of a put option \" \n",
    ">__Answer__ 0 because after getting premium you can only lose. I don't care if my counterparty defaults when I lose money\n",
    "\n",
    "- SWAP PFE : Always think in diffusion versus amortization\n",
    "If you net long short you can reduce the PFE even if products don't have the same Maturity\n",
    "- Samuelson effect : Closer to maturity of forward the volatility increases\n",
    "- Modelling Forward curve correlation --> look at first eigenvalue of all the maturities and the aggregate across industry country.\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 7 \n",
    "\n",
    "## Mortgage Based Securities and CDO's\n",
    "- Before Crisis people used Gaussian copula to price this. = Large Homogeneous Portfolio Approximation [Vasicek] \n",
    "- Always look at Correlation within a tranch \n",
    "-__Trader Convention__ Trade the implied  correlation\n",
    "##### Pricing\n",
    "- Try to model the time of default.  \n",
    "- Look at when the tranche is hit and when it is wiped out.  \n",
    "\n",
    "## CVA \n",
    "- CVA is not linear and in most of the case is not additive because of netting.\n",
    "- CVA = Market Price of Credit  Risk\n",
    "$$ Risky price = Risk Neutral Price - CVA $$\n",
    "\n",
    "`Before Crisis` , CVA was unilaterally charged.  \n",
    "Banks charged CVA to corporates but not amongst each other.  \n",
    "\n",
    "`After crisis` Banks were no longer seen as risk free\n",
    "Now Bilateral CVA = CVA and DVA \n",
    "- DVA can create wrong way risk : I am more likely to default so my equity goes up "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
